<template>
  <div class="center">
    <div class="block">
      <el-date-picker
        type="datetimerange"
        popper-class="test"
        v-model="Time"
        :clearable="true"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
      >
        >
      </el-date-picker>
      <el-button type="primary" @click="getlog">查询</el-button>
    </div>
    <div class="table">
      <dv-border-box-11 :color="['#11caff']" backgroundColor="transparent" title="日志信息">
      <el-table
        :data="tableData"
        class="customer-table"
        height="71.5vh"
        :header-cell-style="headClass"
      >
        <el-table-column prop="userName" label="员工姓名" align="center">
        </el-table-column>
        <el-table-column prop="remoteAddr" label="ip" align="center">
        </el-table-column>
        <el-table-column prop="tableName" label="表名" align="center">
        </el-table-column>
        <el-table-column prop="module" label="模块" align="center">
        </el-table-column>
        <el-table-column prop="data" label="操作数据" align="center">
        </el-table-column>
        <el-table-column prop="operation" label="操作类型" align="center">
        </el-table-column>
      </el-table>
      <el-pagination
        @current-change="handleCurrentChange"
        @prev-click="prevclick"
        @next-click="nextclick"
        :current-page="currentPage"
        :page-size="pagesize"
        layout="total,prev, pager, next"
        :total="total"
      >
      </el-pagination>
      </dv-border-box-11>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      Time: [],
      currentPage: 1,
      total: 0,
      pagesize: 10,
      tableData: [],
    };
  },
  watch:{
    currentPage(){
      this.getlog();
    }
  },
  methods: {
    headClass() {
      return "background-color: transparent;color:#fff;font-weight:bold;";
    },
    //获取日志列表
    getlog() {
      let params = {
        startTime: this.Time[0] || "",
        endTime: this.Time[1] || "",
        page: {
          pageNo: this.currentPage,
          pageSize: this.pagesize,
        },
      };
      this.$http.post("/log/list", params).then((res) => {
        if (res.data.h.code == 0) {
          this.tableData = res.data.b.records;
          this.total = res.data.b.total;
        }
      });
    },
    //上一页
    prevclick() {
      this.currentPage--;
    },
    //下一页
    nextclick() {
      this.currentPage++;
    },
    //分页
    handleCurrentChange(val) {
      this.currentPage = val;
    },
  },
  mounted() {
    this.getlog();
  },
};
</script>
<style scoped>
.block {
  display: inline-block;
  margin-left: 20px;
  margin-top: 20px;
}
.block /deep/.el-range-separator {
  color: #fff;
}
.block /deep/ .el-input__inner {
  color: white;
  background-color: transparent;
  border-color: rgba(19, 81, 156, 1) !important;
}
.block /deep/ .el-range-input {
  color: white;
  background-color: transparent;
  border-color: rgba(19, 81, 156, 1) !important;
}
.el-date-editor {
  margin-right: 20px;
}
.el-date-editor.el-input,
.el-date-editor.el-input__inner {
  width: 300px;
}
.table {
  box-sizing: border-box;
  height:83vh;
}
.table .cell span {
  cursor: pointer;
  color: #007bff;
}
.el-pagination {
  text-align: center;
  margin-top: 20px;
  margin-bottom: 20px;
}
</style>
<style>
.customer-table th {
  border: none;
}
.customer-table td,
.customer-table th.is-leaf {
  border: none;
}
.test{
  background-color: rgba(19, 81, 156, 1);
  color: #fff!important;
}
.test  .el-date-picker__header-label{
  color:#fff!important;
}
.test  .el-picker-panel__icon-btn{
  color:#fff!important;
}
.el-date-table th{
  color:#fff!important;
}
</style>